import actionTypes from "../action";
import { checkImage } from "./rules";
import { OPTION_ORDER_STATUS } from "../options";
export default {
  [actionTypes.REPAIR_QUESTION]: {
    title: "问题",
    form: [
      {
        type: "image",
        prop: "pictureUrl",
        upKey: "pictureFileKey",
        label: "问题图片",
        rule: [
          {
            required: true,
            validator: checkImage,
            trigger: "change",
          },
        ],
      },
      {
        type: "textarea",
        prop: "description",
        label: "问题描述",
        placeholder: "请输入问题描述",
        maxLength: 60,
        rule: {
          required: true,
          message: "请输入问题描述",
          trigger: "blur",
        },
      },
      {
        type: "text",
        prop: "questionType",
        label: "问题类型",
        placeholder: "请输入问题类型",
        rule: {
          required: true,
          message: "请输入问题类型",
          trigger: "blur",
        },
      },
    ],
  },
  [actionTypes.MAINTAIN_ORDER]: {
    title: "维修订单",
    designate: {
      path: "/wel/staffChoose",
      link(item) {
        return item.orderStatus === "NOT_RECEIVING";
      },
    },
    form: [
      {
        type: "image",
        prop: "pictureUrl",
        upKey: "pictureFileKey",
        label: "图片",
      },
      {
        type: "text",
        label: "问题类型",
        prop: "questionType",
        placeholder: "请输入问题类型",
      },
      {
        type: "text",
        label: "问题描述",
        prop: "body",
        placeholder: "请输入问题描述",
      },
      {
        type: "datetime",
        label: "下单时间",
        prop: "gmtCreated",
      },
      {
        type: "text",
        label: "用户",
        prop: "contact",
      },
      {
        type: "text",
        label: "用户电话",
        prop: "mobile",
      },
      {
        type: "text",
        label: "维修地址",
        prop: "address",
      },
      {
        type: "select",
        label: "订单状态",
        prop: "orderStatus",
        option() {
          return OPTION_ORDER_STATUS;
        },
      },
      {
        type: "text",
        label: "员工姓名",
        prop: "staffName",
        topLine: true,
        show(formData) {
          return formData.orderStatus !== "NOT_RECEIVING";
        },
        view(data) {
          return data.staffDTO && data.staffDTO.staffName;
        },
      },
      {
        type: "text",
        label: "员工电话",
        prop: "staffDTO",
        show(formData) {
          return formData.orderStatus !== "NOT_RECEIVING";
        },
        view(data) {
          return data.staffDTO && data.staffDTO.mobile;
        },
      },
      {
        type: "datetime",
        label: "完成时间",
        prop: "finishTime",
        show(formData) {
          return (
            formData.orderStatus !== "NOT_RECEIVING" && formData.finishTime
          );
        },
      },
      {
        type: "text",
        label: "总用时",
        prop: "hour",
        show(formData) {
          return formData.orderStatus !== "NOT_RECEIVING" && formData.hour;
        },
      },
      {
        type: "rate",
        label: "评价",
        prop: "${commentDTO}",
        topLine: true,
        show(formData) {
          return !!formData.commentDTO;
        },
        check_value(commentDTO = {}) {
          return commentDTO.num;
        },
      },
      {
        type: "text",
        label: "评论内容",
        prop: "commentDTO",
        show(formData) {
          return !!formData.commentDTO;
        },
        view(formData) {
          return formData.commentDTO.body;
        },
      },
    ],
  },
};
